package com.ash.okhttp;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

import java.util.concurrent.TimeUnit;

public class Main {


    public static void main(String[] args) {
        OkHttpClient okHttpClient = new OkHttpClient().newBuilder()
                .followRedirects(true)
                .retryOnConnectionFailure(true)
                // 连接超时
                .connectTimeout(30, TimeUnit.SECONDS)
                // 读取超时
                .readTimeout(30, TimeUnit.SECONDS)
                // 写超时
                .writeTimeout(30, TimeUnit.SECONDS)
                .build();

        Request request = new Request.Builder()
                .url("https://s.click.taobao.com/t?e=m%3D2%26s%3DilXi3%2FfrHb1w4vFB6t2Z2ueEDrYVVa64juWlisr3dOdyINtkUhsv0EhwF%2BRBHrWBYDun4d9GyOpQNI4QvO9QIXTi5qOrrrHFUxBsqw6RbbGF7nPyk5NP%2FgcTTBuh%2B%2FGtFBoMXOGuG5DkaqczTKGnOp5e1ah8rgV5zJ%2BQUROo5hHcfxV%2Fdj5fRL7TJXoe6Ozm1s4URdQn8TIT8NY1o36zpKrNaeH0oTlY3kFMn4zWMB0WDg6lOIrqqMygJB9WYv43mPJPM6CpsgtxKmPmpIKZsA%3D%3D&union_lens=lensId%3ATAPI%401717049611%4021501808_127d_18fc821d336_6b9a%40027Pd82QZLLOkikfVoIIxa8n&un=4c7c0feea282a41f46e6040d6f65052e&share_crt_v=1&un_site=0&ut_sk=1.utdid_34565045_1717049613594.TaoPassword-Outside.taoketop&spm=a2159r.13376465.0.0&sp_tk=RU5LQVd3SWNraFA%3D&cpp=1&shareurl=true&short_name=h.g369810")
//                .url("https://s.click.taobao.com/t?e=m%3D2%26s%3DilXi3%2FfrHb1w4vFB6t2Z2ueEDrYVVa64juWlisr3dOdyINtkUhsv0EhwF%2BRBHrWBYDun4d9GyOpQNI4QvO9QIXTi5qOrrrHFUxBsqw6RbbGF7nPyk5NP%2FgcTTBuh%2B%2FGtFBoMXOGuG5DkaqczTKGnOp5e1ah8rgV5zJ%2BQUROo5hHcfxV%2Fdj5fRL7TJXoe6Ozm1s4URdQn8TIT8NY1o36zpKrNaeH0oTlY3kFMn4zWMB0WDg6lOIrqqMygJB9WYv43mPJPM6CpsgtxKmPmpIKZsA%3D%3D&amp;union_lens=lensId%3ATAPI%401717049611%4021501808_127d_18fc821d336_6b9a%40027Pd82QZLLOkikfVoIIxa8n&amp;un=4c7c0feea282a41f46e6040d6f65052e&amp;share_crt_v=1&amp;un_site=0&amp;ut_sk=1.utdid_34565045_1717049613594.TaoPassword-Outside.taoketop&amp;spm=a2159r.13376465.0.0&amp;sp_tk=RU5LQVd3SWNraFA%3D&amp;cpp=1&amp;shareurl=true&amp;short_name=h.g369810&amp;ref=&amp;et=YvrHSFeOstGwEuaTSVFbiyKdM6XFcbfE")
                .get()
                .build();

        try {
            Response response = okHttpClient.newCall(request).execute();

            System.out.println(new String(response.body().bytes()));
            System.out.println(response);


        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
